package com.enation.app.javashop.api.client;

import com.enation.app.javashop.model.trade.order.dto.OrderDTO;
import com.enation.app.javashop.model.trade.order.vo.OrderParam;
import com.enation.app.javashop.model.trade.order.vo.TradeParam;
import com.enation.app.javashop.model.trade.order.vo.TradeVO;
import com.enation.app.javashop.service.trade.order.OrderCenterManager;
import com.enation.app.javashop.service.trade.order.TradeCenterManager;
import com.enation.app.javashop.service.trade.order.TradeIntodbManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

/**
 * @description: 订单中心客户端实现
 * @author: liuyulei
 * @create: 2020-03-23 18:44
 * @version:1.0
 * @since:7.2.0
 **/
@RestController
@RequestMapping("/client/order")
@ApiIgnore
public class OrderCenterClientController {


    @Autowired
    private OrderCenterManager orderCenterManager;

    @Autowired
    private TradeCenterManager tradeCenterManager;

    @Autowired
    private TradeIntodbManager tradeIntodbManager;

    @PostMapping("/create-order")
    public OrderDTO createOrderDTO(@RequestBody OrderParam orderParam) {
        return orderCenterManager.createOrder(orderParam);
    }

    @PostMapping("/create-trade")
    public TradeVO createTradeVO(@RequestBody TradeParam tradeParam) {
        return tradeCenterManager.createTrade(tradeParam);
    }

    @PostMapping("/create")
    public void createTrade(@RequestBody TradeVO tradeVO) {

        tradeIntodbManager.intoDB(tradeVO);
    }

}
